import { defaultInstance } from '@/api/instances'

import type {
  GetVerifyCodeResponseData,
  LoginPayload,
  LoginResponseData,
  RegisterPayload,
  RegisterResponseData,
  SendPhoneVerifyCodeResponseData
} from './types'

export function ApiLogin(payload: LoginPayload) {
  return defaultInstance.Post<LoginResponseData>('/auth/login', payload)
}

export function ApiGetVerifyCode(uuid: string) {
  return defaultInstance.Get<GetVerifyCodeResponseData>(`/verify-code/${uuid}`, {
    localCache: null
  })
}

export function ApiSendPhoneVerifyCode(phone: string) {
  return defaultInstance.Get<SendPhoneVerifyCodeResponseData>(`/verify-code/phone/${phone}`, {
    localCache: null
  })
}

export function ApiRegister(payload: RegisterPayload) {
  return defaultInstance.Post<RegisterResponseData>('/user/register', payload)
}
